﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebApplication2
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                DropDownList2.Items.Add("福建");
                DropDownList2.Items.Add("广东");
                DropDownList2.Items.Add("广西");


               
            }

        }

        protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e)
        {
            string province = DropDownList2.SelectedValue;
            DropDownList3.Items.Clear();
            if (province=="福建")
            {

                DropDownList3.Items.Add("龙岩");
                DropDownList3.Items.Add("福州");
                DropDownList3.Items.Add("厦门");
                DropDownList3.Items.Add("莆田");
                DropDownList3.Items.Add("南平");
            }
            else if (province=="广东")
            {
                DropDownList3.Items.Add("陆丰");
                DropDownList3.Items.Add("广州");
                DropDownList3.Items.Add("深圳");
                DropDownList3.Items.Add("珠海");
                DropDownList3.Items.Add("潮汕");
            }
            else
            {
                DropDownList3.Items.Add("崇左");
                DropDownList3.Items.Add("南宁");
                DropDownList3.Items.Add("北海");
                DropDownList3.Items.Add("桂林");
                DropDownList3.Items.Add("柳州");
            }

        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            string hobby = null;
            for (int i = 0; i < CheckBoxList1.Items.Count; i++)
            {
                if (CheckBoxList1.Items[i].Selected)
                {
                    hobby += CheckBoxList1.Items[i] + "   ";
                }
            }

            if (FileUpload1.HasFile)
            {
                string s1 = FileUpload1.FileName;
                if (s1.EndsWith(".jpg") || s1.EndsWith(".png") || s1.EndsWith(".jpeg"))
                {
                    string s2 = Server.MapPath("/img/" + s1);

                    FileUpload1.SaveAs(s2);
                    Image1.ImageUrl = "/img/" + s1;

                    Image1.Visible = true;
                }
            }
            Label1.Text = $"账号：{TextBox1.Text},密码：{TextBox2.Text},性别：{DropDownList1.SelectedValue},爱好：{ hobby},籍贯：{DropDownList2.SelectedValue},其他信息：{TextBox3.Text}";

          


        }
    }
}